using System;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.ComponentModel;
using System.ComponentModel.Design;
using AjaxControlToolkit;

[assembly: System.Web.UI.WebResource("ReserveSocietyControls.TopicAcordianBehavior.js", "text/javascript")]

namespace ReserveSocietyControls
{
    [Designer(typeof(TopicAcordianDesigner))]
    [ClientScriptResource("ReserveSocietyControls.TopicAcordianBehavior", "ReserveSocietyControls.TopicAcordianBehavior.js")]
    [TargetControlType(typeof(Acms.WebControls.AcmsDataList))]
    public class TopicAcordianExtender : ExtenderControlBase
    {
        // TODO: Add your property accessors here.
        //
        [ExtenderControlProperty]
        [DefaultValue("")]
        public string DivId
        {
            get
            {
                return GetPropertyValue("DivId", "");
            }
            set
            {
                SetPropertyValue("DivId", value);
            }
        }

        [ExtenderControlProperty]
        [DefaultValue(0)]
        public int ItemCount
        {
            get
            {
                return GetPropertyValue("ItemCount", 0);
            }
            set
            {
                SetPropertyValue("ItemCount", value);
            }
        }


        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            Acms.WebControls.AcmsDataList control = base.TargetControl  as Acms.WebControls.AcmsDataList;
            if (control != null && control.Items != null)
            {
                ItemCount = control.Items.Length;
                foreach (Acms.WebControls.AcmsDataListItem item in control.Items)
                {
                    item.Style.Add(HtmlTextWriterStyle.Overflow, "hidden");
                    item.Style.Add(HtmlTextWriterStyle.Height, "35px");
                }
            }
        }
    }
}
